<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ include file="/common/taglibs.jsp"%>
<link rel="stylesheet" type="text/css" href="${ctx}/styles/team.css" media="screen"/>
<div class="dirbar">
	<a style="vertical-align:middle" href="<c:url value='/home.do'/>">首页 </a> &gt;&gt; <a href="<c:url value='/team/list.do'/>">群组</a>
</div>
<div class="dirbar5">
	<span>您可以在此申请创建您爱好的兴趣小组</span>
	<br/>
	<button class="btn3" onclick="javascript:createTeam()">创建组</button>
</div>
<div class="teamlist">
	<table class="t_teamlist">
	<c:forEach var="team" items="${page.items}" varStatus="status">
		<tr style="border-bottom:2px solid #ffbbbb; margin-bottom:10px">
			<td class="t_teamlist_logo">
			<a href="<c:url value='/team/index.do?teamid=${team.teamid}'/>"><img alt="Logo" src="${ctx}/${team.logo}"/></a>
			</td>
			<td class="t_teamlist_desc">
				<div class="t_teamlist_desc_c"><a href="<c:url value='/team/index.do?teamid=${team.teamid}'/>"><c:out value="${team.name}"/></a>
				&nbsp;&nbsp;&nbsp;等级：<c:out value="${team.rank}"/>
				&nbsp;&nbsp;&nbsp;组员：<c:out value="${team.memberCount}"/>
				</div>
				<br/>
				<div class="t_teamlist_desc_d"><c:out value="${team.description}"/></div>
			</td>
			<td class="t_teamlist_fun">
				<c:set var="team_user_status"><ms:team userid="${userid}" type="status" teamid="${team.teamid}"/></c:set>
				<c:if test="${team_user_status==1}">
					<button id="join_team_${team.teamid}" disabled="disabled">已经加入</button>
				</c:if>
				<c:if test="${team_user_status==2}">
					<button id="join_team_${team.teamid}" disabled="disabled">等待审批</button>
				</c:if>
				<c:if test="${team_user_status==3}">
					<button id="join_team_${team.teamid}" disabled="disabled">不允许加入</button>
				</c:if>
				<c:if test="${team_user_status==4}">
					<button id="join_team_${team.teamid}" onclick="javascript:joinTeam(${team.teamid})">申请加入</button>
				</c:if>
			</td>
		</tr>
	</c:forEach>
	</table>
	<jsp:include page="/common/pager.jsp" />
</div>
<script>
function createTeam(){
	var isLogin = '<c:out value="${isLogin}"/>';
	if(isLogin == 'false'){
		alert("请登录");
		return;
	}
	window.location.href = ctx + "/team/create.do";
}
function joinTeam(teamid){
	var isLogin = '<c:out value="${isLogin}"/>';
	if(isLogin == 'false'){
		alert("请登录");
		return;
	}
	$.fn.colorbox({
		 transition:"elastic",
		 width:"400px", 
		 height:"400px",
		 scrolling:false,
		 href:ctx + "/team/apply.do?teamid="+teamid
		 });
}
</script>